package com.xudow.app.dynamicstate_old.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;

import com.jude.utils.JUtils;

public class AutoSquareImageView extends ImageView {
    public AutoSquareImageView(Context context) {
        super(context);
    }

    public AutoSquareImageView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public AutoSquareImageView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init();
    }

    int imageWidth;

    private void init() {
        int width = JUtils.getScreenWidth() - JUtils.dip2px(52);
        imageWidth = width / 4;
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        setMeasuredDimension(imageWidth, imageWidth);
    }
}